package loja.model.handler.impl;

import java.util.HashMap;
import java.util.Map;

import loja.model.handler.HandlerViewEntity;
import loja.model.handler.PropertyView;

public abstract class AbstractHandlerViewEntity<T, PK> implements
		HandlerViewEntity<T, PK> {

	private T entity;
	protected Map<String, PropertyView> propertyViews = new HashMap<>();

	public AbstractHandlerViewEntity(T entity) {
		this.entity = entity;
	}

	@Override
	public T getEntity() {
		return entity;
	}

	@Override
	public void setEntity(T entity) {
		this.entity = entity;
		updateView();
	}

	@Override
	public void addPropertyView(PropertyView propertyView) {
		propertyViews.put(propertyView.getProperty(), propertyView);
	}

	@Override
	public void removePropertyView(PropertyView propertyView) {
		propertyViews.remove(propertyView.getProperty());
	}
}
